#include <vector>
#include <algorithm>

using namespace std;

class Solution
{
public:
    int max(int a, int b)
    {
        return a > b ? a : b;
    }
    int FindGreatestSumOfSubArray(vector<int> array)
    {
        int Max = array[0];
        int sum = 0;
        for (int i = 0; i < array.size(); ++i)
        {
            sum = max(sum + array[i], array[i]);
            Max = max(Max, sum);
        }
        return Max;
    }
};